package com.feng.zshop.common.utils;

import com.feng.zshop.common.constant.ResponseCode;

/**
 * 返回
 *
 * @author Lee
 * @date 2019/2/11
 */
public class ResponseResult {

    public static final String SUCCESS = "success";

    public static final String FAILURE = "failure";

    public ResponseResult() {
    }

    public ResponseResult(int status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static ResponseResult success(String message, Object data) {
        return new ResponseResult(ResponseCode.SUCCESS, message, data);
    }

    public static ResponseResult successNoData(String message) {
        return new ResponseResult(ResponseCode.SUCCESS, message, null);
    }

    public static ResponseResult successNoMessage(Object data) {
        return new ResponseResult(ResponseCode.SUCCESS, SUCCESS, data);
    }

    public static ResponseResult successNotMessageAndData() {
        return new ResponseResult(ResponseCode.SUCCESS, null, null);
    }

    public static ResponseResult fail(String message, Object data) {
        return new ResponseResult(ResponseCode.FAILURE, message, data);
    }

    public static ResponseResult failNoData(String message) {
        return new ResponseResult(ResponseCode.FAILURE, message, null);
    }

    public static ResponseResult failNoMessage(Object data) {
        return new ResponseResult(ResponseCode.FAILURE, FAILURE, data);
    }

    public static ResponseResult failNotMessageAndData() {
        return new ResponseResult(ResponseCode.FAILURE, null, null);
    }

    /**
     * 状态码
     */
    private int status;

    /**
     * 消息
     */
    private String message;

    /**
     * 数据
     */
    private Object data;

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseResult{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
